﻿using System;

namespace CSLive.LiveMaps
{
    public class Color
    {
        private int alpha;
        private int blue;
        private int green;

        private int red;

        public Color( int alpha, int red, int green, int blue )
        {
            this.alpha = alpha;
            this.red = red;
            this.green = green;
            this.blue = blue;
        }

        public int Alpha
        {
            get { return alpha; }
            set { alpha = value; }
        }

        public int Red
        {
            get { return red; }
            set { red = value; }
        }

        public int Green
        {
            get { return green; }
            set { green = value; }
        }

        public int Blue
        {
            get { return blue; }
            set { blue = value; }
        }

        public static Color Parse( int alpha, int red, int green, int blue )
        {
            return new Color( alpha, red, green, blue );
        }

        public static Color Parse( int red, int green, int blue )
        {
            return Parse( 125, red, green, blue );
        }

        public static Color Parse( string argb )
        {
            return Parse( int.Parse( argb.Split( new[] {','} )[ 0 ].Trim() ), int.Parse( argb.Split( new[] {','} )[ 1 ].Trim() ), int.Parse( argb.Split( new[] {','} )[ 2 ].Trim() ), int.Parse( argb.Split( new[] {','} )[ 3 ].Trim() ) );
        }

        public static Color Parse( int alpha, string rgb )
        {
            return Parse( alpha, int.Parse( rgb.Split( new[] {','} )[ 0 ].Trim() ), int.Parse( rgb.Split( new[] {','} )[ 1 ].Trim() ), int.Parse( rgb.Split( new[] {','} )[ 2 ].Trim() ) );
        }

        public override string ToString()
        {
            return string.Format( "{0},{1},{2},{3}", alpha, red, green, blue );
        }
    }
}